package softtech.apps.callblocker;

import java.util.ArrayList;

import softtech.apps.utility.ApplicationConstants;
import softtech.apps.callblocker.adapter.AdapterCallMode;
import softtech.apps.callblocker.adapter.AdapterSmsMode;
import softtech.apps.callblocker.model.DatabaseHanler;
import android.R.color;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class ActivityShowSmsSetting  extends Activity{
	
	private ListView lv;
	private AdapterSmsMode adapter;
	private DatabaseHanler db = new DatabaseHanler(this);
	private static ArrayList<Activity> activities=new ArrayList<Activity>();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_show_call_mode);
		activities.add(this);
		this.setTitleColor(Color.WHITE);
		this.getWindow().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#78b63d")));
		
		setTitle("Seting Mode Blocking Sms");
		Intent intent = getIntent();
		Bundle bundle =intent.getExtras();
		lv = (ListView) findViewById(R.id.lvCallMode);
		adapter = new AdapterSmsMode(this,bundle.getInt("mode"));
		lv.setAdapter(adapter);
		
		// click to choose call mode
		lv.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Intent i = new Intent();
				i.setAction(ApplicationConstants.BROADCAST_ACTION_SMS_SETTING);
				i.putExtra("mode", position + 1);
				i.addCategory(Intent.CATEGORY_DEFAULT);
				sendBroadcast(i);
				finish();
			}
		});
		
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		activities.remove(this);
	}

}
